package com.joysuch.wwyt.bp.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2021/1/14 9:34
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_enterprise_cert")
@SQLDelete(sql = "update wwyt_bp_enterprise_cert set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_enterprise_cert set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class BpEnterpriseCert {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    @ApiModelProperty("证书名称")
    private String certName;
    @ApiModelProperty("证书编号")
    private String certCode;
    @ApiModelProperty("证书附件")
    private String certAttachmentJson;
    @ApiModelProperty("证书类型--数据字典维护")
    private Long certTypeId;
    @ApiModelProperty("发证机构")
    private String releaseOrganization;
    @ApiModelProperty("发证日期")
    private LocalDate releaseDate;
    @ApiModelProperty("有效起始日")
    private LocalDate effectiveStartDate;
    @ApiModelProperty("有效终止日")
    private LocalDate effectiveEndDate;
    @ApiModelProperty("证书描述")
    private String certDescribe;
    @ApiModelProperty("备注")
    private String remark;
    @ApiModelProperty("相关照片")
    private String imgAttachmentJson;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;
    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private LocalDateTime createTime;
    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    private Long updateBy;
    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private LocalDateTime updateTime;
    @ApiModelProperty("租户")
    private Long tenentId;
    @ApiModelProperty("组织机构代码")
    private String orgCode;
    @ApiModelProperty("删除标记")
    private String deleteFlag;

}
